/*
 * @Description: 数据列表
 * @Author: chenju
 * @Date: 2022-01-18 17:21:29
 * @LastEditors: chenju
 * @LastEditTime: 2023-01-19 11:35:45
 */
import { get, getBlob, postBlob } from '@/utils/http';
import type { BasicPagingListParams, BasicPagingListResult } from '@/apis/basicModel';
import type {
  GetTaskDataListParams,
  GetTaskDataListResult,
  GetTaskDataSummaryListParams,
  GetTaskDataSummaryListResult,
  GetTaskDataIdentificationListParams,
  GetTaskDataIdentificationListResult,
  GetTaskDataCollectionListParams,
  GetTaskDataCollectionListResult,
  GetTaskDataCalculationListParams,
  GetTaskDataCalculationListResult,
  GetTaskDataSelectionListParams,
  GetTaskDataSelectionListResult,
  submitTaskDataCalculateParams,
  SubmitTaskDataCalculateResult,
  ExportReportParams
} from './model/dataListModel';
import type { AxiosResponse } from 'axios';

enum Api {
  // 年度盘查清册及报告列表分页查询
  GET_TASK_DATA_LIST = '/inventory/emissionMessage/managerList/page',
  // 汇总页
  GET_TASK_DATA_SUMMARY_LIST = '/inventory/emissionMessage/managerSummary/list',
  // 排放源识别页
  GET_TASK_DATA_IDENTIFICATION_LIST = '/inventory/emissionMessage/managerSource/list',
  // 活动数据收集页
  GET_TASK_DATA_COLLECTION_LIST = '/inventory/emissionMessage/managerActive/list',
  // 排放量计算页
  GET_TASK_DATA_CALCULATION_LIST = '/inventory/emissionMessage/managerCalculation/list',
  // 排放因子选择页
  GET_TASK_DATA_SELECTION_LIST = '/inventory/emissionMessage/managerFactor/list',

  // 列表头数据相关统计
  SUBMIT_TASK_DATA_CALCULATE = '/inventory/emissionMessage/emissions/statistics',
  // 清册导出页面
  SUBMIT_TASK_DATA_INVENTORY_EXPORT = '/inventory/emissionMessage/manager/export',
  // 下载报告页面
  SUBMIT_TASK_DATA_REPORT_EXPORT = '/inventory/report/getFile',
  // 下载报告
  DOWNLOAD_REPORT = '/inventory/emissionMessage/inventoryReport/export'
}

// 年度盘查清册及报告列表分页查询
export const getTaskDataList = (
  params: GetTaskDataListParams & BasicPagingListParams
): Promise<BasicPagingListResult<GetTaskDataListResult>> => get(Api.GET_TASK_DATA_LIST, params);

// 汇总页
export const getTaskDataSummaryList = (
  params: GetTaskDataSummaryListParams
): Promise<BasicPagingListResult<GetTaskDataSummaryListResult>> =>
  get(Api.GET_TASK_DATA_SUMMARY_LIST, params);

// 排放源识别页
export const getTaskDataIdentificationList = (
  params: GetTaskDataIdentificationListParams
): Promise<BasicPagingListResult<GetTaskDataIdentificationListResult>> =>
  get(Api.GET_TASK_DATA_IDENTIFICATION_LIST, params);

// 活动数据收集页
export const getTaskDataCollectionList = (
  params: GetTaskDataCollectionListParams
): Promise<BasicPagingListResult<GetTaskDataCollectionListResult>> =>
  get(Api.GET_TASK_DATA_COLLECTION_LIST, params);

// 排放量计算页
export const getTaskDataCalculationList = (
  params: GetTaskDataCalculationListParams
): Promise<BasicPagingListResult<GetTaskDataCalculationListResult>> =>
  get(Api.GET_TASK_DATA_CALCULATION_LIST, params);

// 排放因子选择页
export const getTaskDataSelectionList = (
  params: GetTaskDataSelectionListParams
): Promise<BasicPagingListResult<GetTaskDataSelectionListResult>> =>
  get(Api.GET_TASK_DATA_SELECTION_LIST, params);

// 列表头数据相关统计
export const submitTaskDataCalculate = (
  params: submitTaskDataCalculateParams
): Promise<SubmitTaskDataCalculateResult> => get(Api.SUBMIT_TASK_DATA_CALCULATE, params);

// 清册导出页面
export const exportInventory = (params: submitTaskDataCalculateParams) =>
  getBlob(Api.SUBMIT_TASK_DATA_INVENTORY_EXPORT, params);

// 下载报告
export const exportReport = (params: ExportReportParams): Promise<AxiosResponse<Blob>> =>
  postBlob(Api.DOWNLOAD_REPORT, params);
